package cn.whb.hrm.mapper;

import cn.whb.hrm.domain.Employee;
import cn.whb.hrm.vo.UserInfo;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author whb
 * @since 2021-12-15
 */
public interface EmployeeMapper extends BaseMapper<Employee> {
    /**
     * 通过id找到用户的信息
     * @param id
     * @return
     */
    @Select("SELECT\n" +
            "\tt1.company_name companyName,\n" +
            "\tt1.id tid,\n" +
            "\tt2.username empName,\n" +
            "\tt2.id empId\n" +
            "FROM\n" +
            "\tt_tenant t1\n" +
            "\tLEFT JOIN t_employee t2 ON t1.admin_id = t2.id \n" +
            "WHERE\n" +
            "\tt2.login_id = #{id}")
    UserInfo findUserInfo(Long id);
}
